proc pharao1:

global id%,id1%,id2%,roomId%
global notes%,name%,wahl%
global wahl$(1)
global up%,dn%,lf%,rg%
global nichts%
global txt1$(40),txt2$(40),txt3$(40)
global txt4$(40),txt5$(40),txt0$(40)
global txt6$(40),txt7$(40),txt8$(40)
global txt9$(40)
global rubin%,saphire%,lantern%,key%,rope%
global pearl%,plaid%,water%,box%,button1%
global button2%,ladder%,done%,points%
global wait%
global finish%
global take%,use%,press%,open%,read%,object%

local col%,lin%
rem rubin%=0
rem saphire%=0
rem lantern%=0
rem key%=0
rem rope%=0
rem pearl%=0
rem plaid%=0
rem water%=0


up%=1 : dn%=1 : lf%=1 : rg%=1

font 6,0
cls

rules::
rem ****************************************
rem 
begin::

id%=gcreate(120,4,240,155,1,1) : gborder 3
id1%=gcreate(360,4,120,155,1,1) : gborder 3
id2%=gcreate(0,4,120,155,1,1) : gborder 3

col%=10
lin%=20

guse id2%
gat 3,3
rem gfill 114,149,1
gfont 10
gstyle 0
gat col%,lin%
gprint "COMMAND KEYS:"
gat col%,lin%+15
gprint "i = informations"
gat col%,lin%+30
gprint "t = take"
gat col%,lin%+45
gprint "u = use"
gat col%,lin%+60
gprint "r =read"
gat col%,lin%+75
gprint "o = open"
gat col%,lin%+90
rem gprint "v = variables"
gat col%,lin%+105
gprint ""
gat col%,lin%+120
gprint "esc = quit game"

roomId%=2

do
  up%=1 
  dn%=1
  lf%=1
  rg%=1
  
  if roomId%=1 : room1:
  elseif roomId%=2 : room2:
  elseif roomId%=3 : room3:
  elseif roomId%=4 : room4:
  elseif roomId%=5 : room5:
  elseif roomId%=6 : room6:
  elseif roomId%=7 : room7:
  elseif roomId%=8 : room8:
  elseif roomId%=9 : room9:
  elseif roomId%=10 : room10:
  elseif roomId%=11 : room11:
  elseif roomId%=12 : room12:
  elseif roomId%=13 : room13:
  elseif roomId%=14 : room14:
  elseif roomId%=15 : room15:
  elseif roomId%=16 : room16:
  elseif roomId%=17 : room17:
  elseif roomId%=18 : room18:
  elseif roomId%=19 : room19:
  elseif roomId%=20 : room20:
  elseif roomId%=21 : room21:
  elseif roomId%=22 : room22:
  elseif roomId%=23 : room23:
  elseif roomId%=24 : room24:
  elseif roomId%=25 : room25:
  elseif roomId%=26 : room26:
  elseif roomId%=27 : room27:
  elseif roomId%=28 : room28:
  elseif roomId%=29 : room29:
  elseif roomId%=30 : room30:
endif

guse id%
rintro:
putinfo:
DoWhat:

wahl$=key$
if wahl$=chr$(27) : finish%=1 : endif
until finish%
endp  rem pharao1 


rem ****************************************
rem 
proc rintro:
local a1%,a2%,a3%
local ll%,cc%     rem basic line & column position of *compass-center*
local col%,lin%   rem basic column & line position of room info
col%=10
lin%=20
ll%=70
cc%=50
guse id1%
gat 3,3
gfill 114,149,1
gat col%,lin%
gfont 12
gstyle 1
gprint "ROOM  ",roomId%
gat col%,lin%+20
gfont 10
gstyle 0
gprint "Ways out are:"
if rg% or lf% or up% or dn%
gat cc%,ll%
gprint chr$(197)
if lf%=1
  gat cc%-15,ll%
  gprint "W"
endif
if rg%=1
  gat cc%+15,ll%
  gprint "E"
endif
if up%=1
  gat cc%,ll%-15
  gprint "N"
endif
if dn%=1
  gat cc%,ll%+15
  gprint "S"
endif
else
  gat cc%-35,ll%-10
  gprint "By Dialogue!"
endif  
gat cc%-40,ll%+25
gprint "Use arrow keys"
gat cc%-40,ll%+40
gprint "to walk around"
gat cc%-40,ll%+55
gprint "You have now:"
gat cc%-40,ll%+70

a1%=notes%+plaid%+key%+rubin%+saphire%
a2%=rope%+lantern%+button1%+button2%
a3%=box%+ladder%+water%+done%
points%=a1%+a2%+a3%
gprint points%,"of 19"
gprint 
endp

rem ****************************************
rem
proc DoWhat:
local diff%
wahl$=""
diff%=0

  do
    wahl$=get$
    if wahl$=chr$(256) and up%
      diff%=diff%+6
    elseif wahl$=chr$(257) and dn%
      diff%=diff%-6
    elseif wahl$=chr$(259) and lf%
      diff%=diff%-1
    elseif  wahl$=chr$(258) and rg%
      diff%=diff%+1 
    elseif wahl$="t"
      take:
    elseif wahl$="i"
      info:
    elseif wahl$="v"
      variable:
    elseif wahl$="u"
      use:
    elseif wahl$="r"
      read:
    elseif wahl$="o"
      open:
    elseif wahl$=chr$(27)
      finish%=1
    endif
  until wahl$<>""
roomId%=roomId%+diff%
endp

rem ****************************************
rem

proc info:
txt1$="You wear in your pockets: "
if rubin% : txt2$="Ruby" : endif
if saphire% : txt3$="Saphire" : endif
if lantern% : txt4$="Lantern" : endif
if rope% : txt5$="Rope" : endif
if pearl% : txt6$="Pearl" : endif
if plaid% : txt7$="Plaid" : endif
if key% : txt8$="Key" : endif
txt9$="... any key to continue..."
wait%=1
putinfo:
endp

rem ****************************************
rem
proc variable:
txt1$="Level of variables:"
txt2$="ruby = "+gen$(rubin%,1)+" / saphire = "+gen$(saphire%,1)
txt3$="lantern = "+gen$(lantern%,1)+" / key = "+gen$(key%,1)
txt4$="rope = "+gen$(rope%,1)+" / pearl = "+gen$(pearl%,1)
txt5$="plaid = "+gen$(plaid%,1)+" / box = "+gen$(box%,1)
txt9$="... any key to continue..."
rem object%=1 rubin%
rem object%=2 saphire%
rem object%=3 lantern%
rem object%=4 key%
rem object%=5 rope%
rem object%=6 pearl%
rem object%=7 plaid%

wait%=1
putinfo:
endp

rem ****************************************
rem
proc putinfo:

local nullcol%
local nulline%
nullcol%=10
nulline%=20

guse id%
gat 3,3
gfill 234,149,1
gfont 6
gstyle 0
gat nullcol%,nulline%
gprint txt1$
gat nullcol%,nulline%+15
gprint txt2$
gat nullcol%,nulline%+30
gprint txt3$
gat nullcol%,nulline%+45
gprint txt4$
gat nullcol%,nulline%+60
gprint txt5$
gat nullcol%,nulline%+75
gprint txt6$
gat nullcol%,nulline%+90
gprint txt7$
gat nullcol%,nulline%+105
gprint txt8$
gat nullcol%,nulline%+120
gprint txt9$
if wait% : get : endif
txt1$="" : txt2$="" : txt3$="" : txt4$=""
txt5$="" : txt6$="" : txt7$="" : txt8$=""
txt9$=""
wait%=0
endp

rem ****************************************
rem

proc take:
if take%
  if object%=1 and rubin%=0
    rubin%=1
  elseif object%=2 and saphire%=0
    saphire%=1
  elseif object%=3 and lantern%=0
    lantern%=1
  elseif object%=4 and key%=0
    key%=1
  elseif object%=5 and rope%=0
    rope%=1
  elseif object%=6 and pearl%=0
    pearl%=1
  elseif object%=7 and plaid%=0
    plaid%=1
  endif
endif
take%=0
object%=0
endp


rem ****************************************
rem
proc use:
if use%
  if object%=1 and rubin%=1
    rubin%=2
  elseif object%=2 and saphire%=1
    saphire%=2
  elseif object%=3 and lantern%=1
    lantern%=2
  elseif object%=4 and key%=1
    key%=2
  elseif object%=5 and rope%=1
    rope%=2
  elseif object%=6 and pearl%=1
    pearl%=2
  elseif object%=7 and plaid%=1
    plaid%=2
  elseif object%=10 and button1%=0
    beep 5,600
    beep 10,300
    button1%=1
    water%=1
  elseif object%=11 and button2%=0
    beep 2,600
    beep 2,550
    beep 2,600
    button2%=1
    ladder%=1
  endif
endif
use%=0
object%=0
endp

rem ****************************************
rem
proc read:
if read%
  if object%=8 and roomId%=8
    txt1$="You see music notes"
    txt2$="They sound very nice..."
    putinfo:
    beep 5,300
    beep 5,400
    beep 5,500
    beep 5,600
    beep 15,300    
    notes%=1
  endif
endif
read%=0
object%=0
endp


rem ****************************************
rem
proc open:
if open%
  if object%=12 and box%=0
    box%=1
  endif
endif
object%=0
open%=0
endp

rem ****************************************
rem
proc room1:
  roomId%=1
  lf%=0
  dn%=0
  txt1$="You're in the desert."
  txt2$="Stars are sparkling in the sky."
  txt3$=""
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room2:
  roomId%=2
  dn%=0
  rg%=0
  txt1$="You're in front of a huge pyramid."
  txt2$="There seems to be a secret door."
  if done%=1 and points%>17
    txt3$="Well,"
    txt4$="YOU HAVE REALLY DONE IT!!!"
    txt6$="Congratulations!"
    txt8$="Any key to quit."
    finish%=1
    beep 4,800
    beep 16,400
    beep 4,800
    beep 16,400
    beep 4,800
    beep 16,400    
    done%=done%+1
  endif
    
endp


rem ****************************************
rem
proc room3:
  roomId%=3
  dn%=0
  up%=0
  lf%=0
  txt1$="A large room."
  txt2$="A blue button is at the wall."
  if button2%=0
    use%=1
    object%=11
  elseif button2%
    txt3$="You did ring, didn't you?"
    txt4$="Maybe, something has happened."
  endif
  
endp

rem ****************************************
rem
proc room4:
  roomId%=4
  dn%=0
  rg%=0
  txt1$="A quiet room."
  txt2$="On a table 's resting a box."
  if box%=0
    open%=1
    object%=12
  elseif box%=1 and rubin%=0
    txt3$="The box is open. Look! A ruby!"
    take%=1
    object%=1
  elseif box% and rubin%
    txt3$="You grabbed a ruby."
  endif
endp

rem ****************************************
rem
proc room5:
  roomId%=5
  dn%=0
  lf%=0
  up%=0
  txt1$="A tiny room."
  if button1%=0
    txt2$="A red button is at the wall."
    use%=1
    object%=10
  elseif button1%
    txt2$="You did ring, didn't you?"
    txt3$="Something did happen anywhere."
    txt4$="(Maybe in room 16?)"
  endif
  txt5$=""

endp

rem ****************************************
rem
proc room6:
  roomId%=6
  dn%=0
  rg%=0
  txt1$="It's room six."
  txt2$="But it doesn't mean anything."
  txt3$=""
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room7:
  roomId%=7
  lf%=0
  up%=0
  rg%=0
  txt1$="You're in the desert."
  txt2$="Stars are sparkling in the sky."
  if lantern%=0
    txt3$="You see a lantern in the sand."
    take%=1
    object%=3
  else
    txt3$="You took a lantern already."
  endif
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room8:
  roomId%=8
  lf%=0
  up%=0
  txt1$="You're inside the pyramide."
  if lantern%=0
    txt2$="It's very dark. You need a lantern."
  elseif lantern%=1
    txt2$="It's very dark in here!"
    txt3$="How can you change this?"
    use%=1
    object%=3
  elseif lantern%=2
    txt2$="Your lantern shines very bright"
    txt3$="There are signs at the wall"
    txt4$="There is a button at the wall."
    read%=1
    object%=8    
  endif
  txt5$=""

endp

rem ****************************************
rem
proc room9:
  roomId%=9
  up%=0
  dn%=0
  txt1$="You're in a long walk"
  if lantern%<>2
    txt2$="It's dark, you don't see anything"
  else 
    txt2$=""
  endif
  txt3$=""
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room10:
  roomId%=10
  txt1$="This room is long but empty."
  txt2$=""
  txt3$=""
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room11:
  roomId%=11
  dn%=0
  txt1$="Another empty room."
  txt2$=""
  txt3$=""
  txt4$=""
  txt5$=""
  
endp

rem ****************************************
rem
proc room12:
  roomId%=12
  up%=0
  rg%=0
  txt1$="A cool room."
  if plaid%=0
    txt2$="There is a plaid at the floor."
  elseif plaid%=1
    txt2$="Once you've taken a plaid."
  endif
  if plaid% and  not key%
    txt3$="You find a golden key."
  elseif plaid% and key%
    txt3$="... and a golden key ..."
  endif
  txt4$=""
  txt5$=""
  if not plaid%
    take%=1
    object%=7
  endif
  if plaid% and not key%
    take%=1
    object%=4
  endif  
endp

rem ****************************************
rem
proc room14:
  roomId%=14
  rg%=0
  lf%=0
  dn%=0
  txt1$="On the ground of the pit"
  txt2$="you find a saphire"
  if rope%<>3
    txt3$="You can take it, but "
    txt5$="YOU LOST THE GAME"
    txt7$="since you didn't use the rope."
    txt8$="Any key to quit"
    beep 2,400
    beep 4,450
    beep 4,500
    beep 8,600
    beep 32,800
    finish%=1
  endif
  if saphire%=0
    take%=1
    object%=2
  elseif saphire%=1
    txt3$="... and you took it."
  endif

endp

rem ****************************************
rem
proc room15:
  roomId%=15
  lf%=0
  dn%=0
  txt1$="This room is empty."
  txt2$="You should leave quickly, danger!"
  txt3$=""
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room16:
  roomId%=16
  rg%=0
  up%=0
  txt1$="The room reminds me on my cellar."
  if water%=0
    txt2$="Oh, Gawd! So much water!"
    txt3$="No way through."
    lf%=0
  elseif water%=1
    txt2$="Where's all the water gone?"
    txt3$="You are able to pass the room."
    if rope%=0
      txt4$="I wonder what this rope is good for"
      take%=1
      object%=5
    elseif rope%
      txt4$="Here you found the rope."
    endif
  endif

endp

rem ****************************************
rem
proc room17:
  roomId%=17
  lf%=0
  rg%=0
  txt1$="A dead end room?"
  if ladder%=0
    txt2$="Something is at the ceiling."
    txt3$="(Maybe the button in r.3 helps?)"
    up%=0
  elseif ladder%=1
    txt2$="No. Now you can pass."
    txt3$="A ladder leads to next floor."
  endif
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room20:
  roomId%=20
  up%=0
  lf%=0
  txt1$="A misterious room."
  txt2$="In the middle you see a pit"
  txt3$="At the wall is a hook"
  if rope%=0
    rem
  elseif rope%=1
    use%=1
    object%=5
  elseif rope%=2
    txt4$="You tighten the rope at the"
    txt5$="hook and are able to climb down"
    rope%=3
  elseif rope%=3
    rem
  endif
  
endp


rem ****************************************
rem
proc room21:
  roomId%=21
  up%=0
  rg%=0
  txt1$="A long and winding room"

endp


rem ****************************************
rem
proc room22:
  roomId%=22
  lf%=0
  up%=0
  dn%=0
  txt1$="An extra large room."
  txt2$="You find a casket in the corner."
  txt3$="Don't waste time, it's empty."

endp

rem ****************************************
rem
proc room23:
  roomId%=23
  up%=0
  ladder%=0
  txt1$="No room to sit 'n dream."
  txt2$=""
  txt3$=""
  txt4$=""
  txt5$=""

endp

rem ****************************************
rem
proc room24:
  roomId%=24
  rg%=0
  dn%=0
  up%=0
  txt1$="One step to the burial place"
  txt2$="of the pharao's mummy"
  txt3$="In the north is a door."
  if key%=0
    txt4$="You need a key."
  elseif key%=1
    use%=1
    object%=4
    txt4$="It is locked."
  elseif key%=2
    txt4$="The door is unlocked now."
    up%=1
  endif

endp

rem ****************************************
rem
proc room30:
  roomId%=30
  rg%=0
  up%=0
  lf%=0
  txt1$="Pharao's burial place"
  txt2$="There is the mummy,"
  txt3$="the eyes' sockets, once filled"
  if rubin%=1 and saphire%=1
    txt4$="with 2 jewels, are empty now."
    use%=1
    object%=1
  elseif rubin%=2 and saphire%=1
    txt4$="with 2 jewels, have back one of it"
    use%=1
    object%=2
  elseif rubin%=2 and saphire%=2
    txt4$="with 2 jewels, have back both."
    txt5$="Look! The mummy gets up and "
    txt6$="escapes. Follow, 'cause you've"
    txt7$="forgotten to shoot a photo of it."
    txt8$="Nobody will believe your story."
    done%=1
  endif
endp


